package lynch.map 
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import lynch.net.loading.LynchLoader;
	
	/**
	 * only open for WorldMap
	 * @author 小痛
	 */
	internal class Tile extends Bitmap 
	{
		public var id:int;
		private var lyloader:LynchLoader;
		
		public function Tile(bitmapData:BitmapData) 
		{
			super(bitmapData);
			cacheAsBitmap = true;
		}
		
		public function updateInfo(id:int, mapID:int):void
		{
			this.id = id;
			lyloader && lyloader.close();
			lyloader = new LynchLoader("resource/image/mapTiles/" + mapID + "/" + id + ".jpg", onTileLoaded, true, "binary");
			lyloader.load(null);
		}
		
		private function onTileLoaded(l:LynchLoader):void 
		{
			//bitmapData.dispose();
			//bitmapData = l.data.bitmapData;
			//scaleX = scaleY = 1;
			lyloader = null;
		}
	}
}